package com.miplus.ccrm.uploadjob.controller;

import com.miplus.ccrm.common.R;
import com.miplus.ccrm.uploadjob.controller.vo.UpRecResVo;
import com.miplus.ccrm.uploadjob.service.impl.TRecorderService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/file")
public class fileController {

    @Resource
    private TRecorderService recorderService;

    /**
     * 调听本地录音
     */
    @RequestMapping(value = "playRecord", method = RequestMethod.GET)
    public R playRecord(String callid,String agentid,HttpServletResponse response) {
        recorderService.OnPlayRecord(callid,agentid,response);
        return R.Success();
    }

    /**
     * 上载录音文件
     */
    @RequestMapping(value = "uploadRecord", method = RequestMethod.POST)
    public R<UpRecResVo> uploadRecord(@RequestParam("file") MultipartFile file) {
        return R.Success(recorderService.UploadRecord(file));
    }
}
